<?php

/**
 * 店铺前台模块
 * @author ezhu <ezhu@jipukeji.com>
 * @version 1.0
 */

namespace Home\Model;

use Think\Model;

class StoreModel extends Model{
    
    protected $tableName = 'store';
    
    
    /**
     * 是否已是卖家
     */
    public function isSeller($member_id=0){
        if(empty($member_id)){
            return false;
        }
        $map['member_id'] = $member_id;
        $data = M('Seller')->where($map)->find();
        return !empty($data) ? true : false;
    }
    
    
    /**
     * 店铺列表
     * @param unknown $map
     * @param string $field
     * @param string $order
     * @param string $limit
     * @return unknown
     */
    public function lists($map = array(), $field = true, $order = '`store_id` DESC, `time` DESC', $limit = '50'){
        !$map['status'] && $map['status'] = 1;
        $list = $this->where($map)->field($field)->order($order)->limit($limit)->select();
        if($list && is_array($list)){
            foreach ($list as $key => &$value){
                if($value['logo']){
                    $value['logo'] = get_cover($value['logo'], 'path');
                }
            }
        }
        return $list;
    }
    
    
    
}